﻿// Write a program that reads from the console a positive integer number N (N < 20) and outputs a matrix like the following:
// N = 3            N = 4
// 1  2  3          1  2  3  4 
// 2  3  4          2  3  4  5
// 3  4  5          3  4  5  6
//                  4  5  6  7

using System;

class PrintMatrix
{
    static void Main()
    {
        Console.Write("Enter N less than 20 : ");
        string numberStr = Console.ReadLine();
        int numberN;
        while (! int.TryParse(numberStr, out numberN))
        {
            Console.Write("Inavlid input. Try enter N bigger than 0 and less than 20 : ");
             numberStr = Console.ReadLine();
        }

        if (numberN <= 0 || numberN >= 20)
        {
            Console.WriteLine("Invalid input. N must be bigger than 0 and less than 20.");
        }
        else
        {

            for (int row = 1; row <= numberN; row++)
            {
                for (int col = row; col <= numberN + row - 1; col++)
                {
                    Console.Write("{0, -5}", col);
                }
                Console.WriteLine();
            }
        }
    }
}
